<template>
  <el-tooltip class="item" effect="dark"
              :content="timestamp"
              placement="top-start"
              :type="type">
    <span :style="style">{{ str }}</span>
  </el-tooltip>
</template>

<script setup>
import {computed} from "vue";
import {isNullOrUndefinedOrEmpty} from "@/config/common";
import {formatTime} from "@/utils";

const props = defineProps({
  timestamp: {
    type: [String, Number],
    default: null,
  },
  type: {
    type: String,
    default: null,
  },
  style: {
    type: String,
    default: null,
  },
})

const str = computed(() => {
  const val = props.timestamp
  if (isNullOrUndefinedOrEmpty(val)) {
    return ''
  }
  return formatTime(Date.parse(val), false)
})
</script>
